import { createSlice } from "@reduxjs/toolkit";
import request from "../../utils/request";

const userStore = createSlice({
    name: 'token',
    initialState: {
        token: ''
    },
    reducers: {
        setUserInfo(state, action){
            state.token = action.payload
        }
    }
})
const login = (loginForm) => {
    return async (dispatch) => {
        const res = await request.post('/authorizations', loginForm)
        dispatch(userStore.actions.setUserInfo(res.data.data))
    }
}
export default (userStore, login)
